package com.crazy.entity.sys;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.GenericGenerator;

/**
 * 资源 entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "pub_resource", uniqueConstraints = @UniqueConstraint(columnNames = "authority_name"))
public class PubResource implements java.io.Serializable {
	private String resourceId;
	private PubResource pubResource;
	private String resourceName;
	private String resourceDesc;
	private String resourceType;
	private String resourceUrl;
	private String authorityName;
	private Integer priority;
	private Integer enabled;
	private String creator;
	private Date createTime;
	private List<PubRole> pubRoles = new ArrayList<PubRole>(0);
	private List<PubResource> pubResources = new ArrayList<PubResource>(0);
	private String target;

	/** default constructor */
	public PubResource() {
	}

	@Id
	@Column(name = "resource_id", unique = true, nullable = false, length = 32)
	@GenericGenerator(name = "generator", strategy = "uuid")
	@GeneratedValue(generator = "generator")
	public String getResourceId() {
		return this.resourceId;
	}

	public void setResourceId(String resourceId) {
		this.resourceId = resourceId;
	}

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "parent_id")
	public PubResource getPubResource() {
		return this.pubResource;
	}

	public void setPubResource(PubResource pubResource) {
		this.pubResource = pubResource;
	}

	@Column(name = "resource_name", length = 100)
	public String getResourceName() {
		return this.resourceName;
	}

	public void setResourceName(String resourceName) {
		this.resourceName = resourceName;
	}

	@Column(name = "resource_desc", length = 1000)
	public String getResourceDesc() {
		return this.resourceDesc;
	}

	public void setResourceDesc(String resourceDesc) {
		this.resourceDesc = resourceDesc;
	}

	@Column(name = "resource_type", length = 100)
	public String getResourceType() {
		return this.resourceType;
	}

	public void setResourceType(String resourceType) {
		this.resourceType = resourceType;
	}

	@Column(name = "resource_url", length = 1000)
	public String getResourceUrl() {
		return this.resourceUrl;
	}

	public void setResourceUrl(String resourceUrl) {
		this.resourceUrl = resourceUrl;
	}

	@Column(name = "authority_name", unique = true, length = 100)
	public String getAuthorityName() {
		return this.authorityName;
	}

	public void setAuthorityName(String authorityName) {
		this.authorityName = authorityName;
	}

	@Column(name = "priority")
	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	@Column(name = "enabled")
	public Integer getEnabled() {
		return this.enabled;
	}

	public void setEnabled(Integer enabled) {
		this.enabled = enabled;
	}

	@Column(name = "creator", length = 100)
	public String getCreator() {
		return this.creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	@Column(name = "create_time", length = 19)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@ManyToMany(cascade = ALL, fetch = LAZY, mappedBy = "pubResources")
	public List<PubRole> getPubRoles() {
		return this.pubRoles;
	}

	public void setPubRoles(List<PubRole> pubRoles) {
		this.pubRoles = pubRoles;
	}

	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "pubResource")
	public List<PubResource> getPubResources() {
		return this.pubResources;
	}

	public void setPubResources(List<PubResource> pubResources) {
		this.pubResources = pubResources;
	}

	@Column(name = "target", length = 100)
	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}
}